using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Service.Order.IOrderService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2024-12-03
namespace JTZY.Admin.WebApi.Controllers.Order
{
    /// <summary>
    /// 退货单明细表
    /// </summary>
    [Verify]
    [Route("order/Corecmsbillreshipitem")]
    public class CorecmsbillreshipitemController : BaseController
    {
        /// <summary>
        /// 退货单明细表接口
        /// </summary>
        private readonly ICorecmsbillreshipitemService _CorecmsbillreshipitemService;

        public CorecmsbillreshipitemController(ICorecmsbillreshipitemService CorecmsbillreshipitemService)
        {
            _CorecmsbillreshipitemService = CorecmsbillreshipitemService;
        }

        /// <summary>
        /// 查询退货单明细表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsbillreshipitem:list")]
        public IActionResult QueryCorecmsbillreshipitem([FromQuery] CorecmsbillreshipitemQueryDto parm)
        {
            var response = _CorecmsbillreshipitemService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询退货单明细表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "corecmsbillreshipitem:query")]
        public IActionResult GetCorecmsbillreshipitem(int Id)
        {
            var response = _CorecmsbillreshipitemService.GetInfo(Id);
            
            var info = response.Adapt<CorecmsbillreshipitemDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加退货单明细表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsbillreshipitem:add")]
        [Log(Title = "退货单明细表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsbillreshipitem([FromBody] CorecmsbillreshipitemDto parm)
        {
            var modal = parm.Adapt<Corecmsbillreshipitem>().ToCreate(HttpContext);

            var response = _CorecmsbillreshipitemService.AddCorecmsbillreshipitem(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新退货单明细表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsbillreshipitem:edit")]
        [Log(Title = "退货单明细表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsbillreshipitem([FromBody] CorecmsbillreshipitemDto parm)
        {
            var modal = parm.Adapt<Corecmsbillreshipitem>().ToUpdate(HttpContext);
            var response = _CorecmsbillreshipitemService.UpdateCorecmsbillreshipitem(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除退货单明细表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsbillreshipitem:delete")]
        [Log(Title = "退货单明细表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsbillreshipitem([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CorecmsbillreshipitemService.Delete(idArr));
        }

    }
}